feat(epp): order all requestcontrol hooks by data-dependency DAG#15
feat(epp): order all requestcontrol hooks by data-dependency DAG#15chethanuk wants to merge 3 commits into
Conversation
ValidateAndOrderDataDependencies already produced a topological order, but only DataProducer plugins were reordered. Other extension points kept the map-iteration order from GetAllPlugins, so PreRequest (and related hooks) could run consumers before producers across restarts (llm-d#1856 class of bug). Make TopologicalSort deterministic via a largest-ready tie-break (so the existing reverse yields ascending name ties), apply that order to all six requestcontrol hook lists while retaining unranked plugins, and document that Consumes/Produces govern every requestcontrol extension point. Signed-off-by: ChethanUK <chethanuk@outlook.com>
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Review limit reached
Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe request-control configuration now orders all hook plugins from the dependency DAG, with deterministic handling for ties and unranked plugins. Topological sorting receives deterministic tie-breaking, and tests cover hook-list ordering, edge cases, dependency shapes, and cycle detection. ChangesRequest-control plugin ordering
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the plugin ordering mechanism to ensure deterministic execution across all request control extension points, addressing potential order-dependency issues. It introduces a unified OrderPlugins method, refactors the topological sort utility to break ties deterministically, and adds comprehensive unit tests. The reviewer provided valuable feedback on performance optimizations: first, to avoid sorting the entire queue in Kahn's algorithm by finding the maximum element in linear time; and second, to cache plugin names and ranks prior to sorting in orderByName to eliminate redundant string formatting and map lookups.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
CodeAnt AI finished reviewing your PR. |
The whole point of ordering every hook list by the data-dependency DAG is that the result must not depend on Go's randomized map iteration in GetAllPlugins. The existing tests fed a single input order, so a regression that reintroduced input-order sensitivity could pass. Drive several fixed permutations of the same plugin set and assert every hook list comes out identical. Signed-off-by: ChethanUK <chethanuk@outlook.com>
Ordering every requestcontrol hook list by the data-dependency DAG makes execution deterministic, which is the goal. The producer-before-consumer direction is right for the request-path hooks, but for ResponseHeader and ResponseBody a producer may release the state a consumer reads, so the correct direction there is not established. Document it as unsettled rather than asserting producer-first is canonical for response hooks. Signed-off-by: ChethanUK <chethanuk@outlook.com>
User description
What type of PR is this?
/kind bug
/kind feature
What this PR does / why we need it:
ValidateAndOrderDataDependenciesalready built a topological order of requestcontrol plugins, but onlyDataProducerplugins were reordered. The other five hook lists (PreRequest,RequestHeader,Admission,ResponseReceived,ResponseStreaming) kept the map-iteration order fromGetAllPlugins, so a consumer could run before its producer after a restart (the llm-d#1856 class of bug).This PR:
TopologicalSortdeterministic with a largest-ready Kahn tie-break (so the existing reverse yields ascending name ties).OrderDataProducerPluginswithOrderPlugins, which reorders all six requestcontrol hook lists by the DAG rank while retaining unranked plugins (stable append by name).Consumes/Producesgovern every requestcontrol extension point.Not a duplicate of llm-d#1421 / PR llm-d#1876: that work ordered plugin instantiation in the config loader; this orders hook execution in requestcontrol.
Which issue(s) this PR fixes:
Fixes llm-d#2040
How to test:
make test-filter PATTERN=TestConfig_OrderPlugins_AllHookLists TYPE=epp epp_TEST_PACKAGES='./pkg/epp/requestcontrol/'— 6 subtests PASS (all six lists ordered; unranked retained)make test-filter PATTERN=TestTopologicalSort_Deterministic TYPE=epp epp_TEST_PACKAGES='./pkg/epp/util/'— PASSmake test-filter PATTERN=TestDAGAndTopologicalOrder TYPE=epp epp_TEST_PACKAGES='./pkg/epp/datalayer/'— PASSmake test-filter PATTERN='TestPluginsWithDependencies|TestFilterExecutionOrderFromYAML' TYPE=epp epp_TEST_PACKAGES='./pkg/epp/config/loader/'— PASS (2nd TopologicalSort caller / instantiation order)make lint— 0 issuesmake build— epp + sidecarmake test-unit-epp(excl. pre-existingpkg/kvcache/kvblockfull-suite load flake; package green in isolation) +make test-unit-sidecarRelease note (write
NONEif no user-facing change):CodeAnt-AI Description
Order every request hook by data dependencies
What Changed
Impact
✅ Fewer cases where a consumer runs before its producer✅ Stable hook order after restart✅ More predictable request processing💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
Improvements
Bug Fixes